
#ifndef __JTAG_H__
#define __JTAG_H__

#include "../library/arm7.h"

/* provided by host */
void jtag_srst(unsigned hi);

/* transport layer */
void jtag_init(void);
void jtag_reset(void);
unsigned jtag_get_id(void);

unsigned jtag_dbg_io(unsigned out, unsigned bkpt);
unsigned jtag_ice_rd(unsigned reg);
void jtag_ice_wr(unsigned reg, unsigned out);

void jtag_select_ice();
void jtag_select_debug();
void jtag_select_restart();


/* arm7tdmi debug layer */
unsigned jtag_reg_rd(unsigned r);
void jtag_reg_wr(unsigned r, unsigned v);

unsigned jtag_mem_rd(unsigned a);
void jtag_mem_wr(unsigned a, unsigned v);

int jtag_halt_cpu(int reset);
unsigned jtag_cpsr_rd(void);

#endif
